package org.shiro.exception;

import com.alibaba.fastjson.JSONObject;
import org.apache.shiro.authc.AuthenticationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/** @author LENOVO */
@RestControllerAdvice
public class GlobalException {
  @ExceptionHandler(value = AuthenticationException.class)
  @ResponseBody
  public JSONObject Exception(AuthenticationException ex) {
    JSONObject json = new JSONObject();
    json.put("errorCode", 401);
    json.put("errorMsg", ex.getMessage());
    return json;
  }
}
